import numpy
import random


# add salt and pepper noise
# spectrum: spectrum
# count: count of points
def add_s_p_noise(spectrum, count, points):
    new_points = []

    i = 0
    while i < count:
        x = random.randint(0, 97)
        y = random.randint(0, 49)
        if (x, y) not in new_points:
            if spectrum[x][y] < 1:
                if (points[y][x >> 3] & (1 << (x & 7))) == 0:
                    new_points.append((x, y))
                    i = i+1
    for x, y in new_points:
            spectrum[x][y] = 2.0

    return spectrum,new_points
